package com.pubinfo.passbook.common.service.ruler.MergeStrategy;

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.pubinfo.passbook.common.model.ruler.Reimbursement;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;

import java.util.ArrayList;
import java.util.List;

//单元格合并策略
public class MyMergeStrategy extends AbstractMergeStrategy {
  
  private final List<Reimbursement> reimbursement;
  
  //构造
  public MyMergeStrategy(List<Reimbursement> reimbursement) {
    this.reimbursement = reimbursement;
  }
  
  @Override
  protected void merge(Sheet sheet, Cell cell, Head head, Integer integer) {
    sheet.addMergedRegionUnsafe(new CellRangeAddress(reimbursement.size() + 1, reimbursement.size() + 1, 0, 8));
    sheet.addMergedRegionUnsafe(new CellRangeAddress(reimbursement.size() + 2, reimbursement.size() + 2, 0, 2));
    sheet.addMergedRegionUnsafe(new CellRangeAddress(reimbursement.size() + 2, reimbursement.size() + 2, 3, 5));
    sheet.addMergedRegionUnsafe(new CellRangeAddress(reimbursement.size() + 2, reimbursement.size() + 2, 6, 8));
    sheet.addMergedRegionUnsafe(new CellRangeAddress(reimbursement.size() + 2, reimbursement.size() + 2, 9, 11));
  }
}
